{template 'common/header'}
{php echo $this -> set_tabbar($action, 3);}
{if $operation == 'display'}
<div class="main">
    <style>
        .form-control-excel {
            height: 34px;
            padding: 6px 12px;
            font-size: 14px;
            line-height: 1.42857143;
            color: #555;
            background-color: #fff;
            background-image: none;
            border: 1px solid #ccc;
            border-radius: 4px;
            -webkit-box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
            box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
            -webkit-transition: border-color ease-in-out .15s,-webkit-box-shadow ease-in-out .15s;
            -o-transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
            transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
        }
    </style>
    <div class="panel panel-default">
        <div class="panel-body">
            <form action="./index.php" method="post" class="form-horizontal form" enctype="multipart/form-data">
                <input type="hidden" name="leadExcel" value="true">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="weisrc_icard" />
                <input type="hidden" name="do" value="UploadExcel" />
                <input type="hidden" name="ac" value="olduser" />
                <a class="btn btn-primary" href="{php echo $this->createWebUrl('olduser', array('op' => 'post'))}"><i class="fa fa-plus"></i> 添加实体会员</a>
                <a class="btn btn-primary" href="javascript:location.reload()"><i class="fa fa-refresh"></i> 刷新</a>
                <input name="viewfile" id="viewfile" type="text" value="" style="margin-left: 40px;" class="form-control-excel" readonly>
                <a class="btn btn-primary"><label for="unload" style="margin: 0px;padding: 0px;">上传...</label></a>
                <input type="file" class="pull-left btn-primary" name="inputExcel" id="unload" style="display: none;" onchange="document.getElementById('viewfile').value=this.value;this.style.display='none';">
                <input type="submit" class="btn btn-primary" name="btnExcel" value="导入数据">
                <a class="btn btn-primary" href="../addons/weisrc_icard/example/example_olduser.xls">下载导入模板</a>
            </form>
        </div>
    </div>
    <div class="panel panel-info">
        <div class="panel-heading">筛选</div>
        <div class="panel-body">
            <form action="./index.php" method="get" class="form-horizontal" role="form">
                <input type="hidden" name="c" value="site" />
                <input type="hidden" name="a" value="entry" />
                <input type="hidden" name="m" value="weisrc_icard" />
                <input type="hidden" name="do" value="olduser" />
                <input type="hidden" name="op" value="display" />
                <div class="form-group">
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">关键字</label>
                    <div class="col-sm-2 col-lg-2">
                        <input type="text" id="keyword" name="keyword" value="{$keyword}" class="form-control-excel" placeholder="请输入关键词" data-rule-required="true">
                    </div>
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">类型</label>
                    <div class="col-sm-2 col-lg-2">
                        <select name="type" class="input-small form-control">
                            <option {if $type=='cardno' || empty($type)}selected="selected"{/if} value="cardno">卡号</option>
                            <option {if $type=='username'}selected="selected"{/if} value="username">用户名</option>
                            <option {if $type=='tel'}selected="selected"{/if} value="tel">手机号码</option>
                        </select>
                    </div>
                    <label class="col-xs-12 col-sm-2 col-md-2 col-lg-1 control-label">状态</label>
                    <div class="col-sm-2 col-lg-2">
                        <select name="status" class="input-small form-control">
                            <option {if $status=='-1' || empty($status)}selected="selected"{/if} value="-1">全部</option>
                            <option {if $status=='0'}selected="selected"{/if} value="0">未绑定</option>
                            <option {if $status=='1'}selected="selected"{/if} value="1">已绑定</option>
                        </select>
                    </div>
                    <div class="col-sm-3 col-lg-2">
                        <input type="hidden" name="token" value="{$_W['token']}" />
                        <input name="submit" type="submit" class="btn btn-primary" value="查询">
                        <button class="btn btn-success" name="out_put" value="output"><i class="fa fa-file"></i> 导出</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <form action="" method="post" class="form-horizontal form" >
        <div class="panel panel-default">
            <div class="table-responsive panel-body">
                <table class="table table-hover">
                    <thead class="navbar-inner">
                    <tr>
                        <th style="width:10%;">卡号</th>
                        <th style="width:10%;">姓名</th>
                        <th style="width:15%;">电话</th>
                        <th style="width:10%;">性别</th>
                        <th style="width:15%;">身份证</th>
                        <th style="width:10%;">预存余额</th>
                        <th style="width:10%;">预存积分</th>
                        <th style="width:10%;">状态</th>
                        <th style="width:10%;">操作</th>
                    </tr>
                    </thead>
                    <tbody id="level-list">
                    {loop $list $item}
                    <tr>
                        <td>{$item['cardno']}</td>
                        <td>{$item['username']}</td>
                        <td>{$item['mobile']}</td>
                        <td>
                            {if $item['sex'] == 1}
                            男
                            {else}
                            女
                            {/if}
                        </td>
                        <td>{$item['idcard']}</td>
                        <td>{$item['credit']}</td>
                        <td>{$item['coin']}</td>
                        <td>
                            {if $item['status'] == 1}
                            <span class="label label-success">已绑定</span>
                            {else}
                            <span class="label label-danger">未绑定</span>
                            {/if}
                        </td>
                        <td>
                            <a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('olduser', array('id' => $item['id'], 'op' => 'post'))}"><i class="fa fa-pencil"></i></a>
                            <a class="btn btn-default btn-sm" href="{php echo $this->createWebUrl('olduser', array('id' => $item['id'], 'op' => 'delete'))}" onclick="return confirm('此操作不可恢复，确认删除？');return false;" title="删除"><i class="fa fa-times"></i></a>
                        </td>
                    </tr>
                    {/loop}
                    </tbody>
                </table>
            </div>
        </div>
    </form>
    {$pager}
    <div id="modal-module-menus-recharge"  class="modal fade" tabindex="-1">
        <div class="modal-dialog" style='width: 520px;'>
            <div class="modal-content">
                <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>会员充值</h3></div>
                <div class="modal-body">
                    <form id="Form1" action="{php echo $this->createWebUrl('addCardPrice')}" method="post" class="form-horizontal">
                        <input type="hidden" name="id" id="id" value="0">
                        <input type="hidden" name="status" id="status" value="0">
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">充值金额</label>
                            <div class="col-sm-9">
                                <div class="input-append">
                                    <input type="text" placeholder="金额" name="price" id="price" class="form-control" data-rule-required="true" data-rule-number="true">
                                    <span class="add-on"><i class="icon-cny"></i></span>
                                </div>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">操作原因</label>
                            <div class="col-sm-9">
                                <textarea name="remark" id="remark" class="form-control"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                            <div class="col-sm-9">
                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div id="modal-module-menus-score"  class="modal fade" tabindex="-1">
        <div class="modal-dialog" style='width: 520px;'>
            <div class="modal-content">
                <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>赠送积分(增减)</h3></div>
                <div class="modal-body">
                    <form id="Form2" action="{php echo $this->createWebUrl('addCardScore')}" method="post"
                          class="form-horizontal  form-modal">
                        <input type="hidden" name="id" id="id2" value="{$item['id']}">
                        <input type="hidden" name="status" id="status2" value="{$item['status']}">
                        <div class="form-group" style="margin-bottom: 0px;">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">赠送积分</label>
                            <div class="col-sm-9">
                                <input type="text" placeholder="积分" name="score" id="score" class="form-control"
                                       data-rule-required="true" data-rule-number="true">
                                <span class="help-block" style="padding:0px;color:#f00;">
                                    输入500,表示增加500;<br>输入-500表示减少500;
                                </span>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label">操作原因</label>
                            <div class="col-sm-9">
                                <textarea name="remark" class="form-control"></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
                            <div class="col-sm-9">
                                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $("tr").delegate(".pay", "click", function () {
            $("#price").val("100");
            $("#id").val($(this).attr("data-codeid"));
            $("#status").val($(this).attr("data-status"));
            $('#modal-module-menus-recharge').modal();
        });

        $("tr").delegate(".bestow", "click", function () {
            $("#score").val("100");
            $("#id2").val($(this).attr("data-memberid"));
            $("#status2").val($(this).attr("data-status"));
            $('#modal-module-menus-score').modal();
        });
    });
</script>
{elseif $operation == 'post'}
<div class="main">
    <form action="" method="post" onsubmit="return check();" class="form-horizontal form" enctype="multipart/form-data">
        <h4>{$title}</h4>
        <div class="panel panel-default">
            <div class="panel-heading">
                会员编辑
            </div>
            <div class="panel-body">
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">卡号</label>
                    <div class="col-sm-9">
                        <input type="text" name="cardno" id="cardno" value="{$item['cardno']}" class="form-control" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">姓名</label>
                    <div class="col-sm-9">
                        <input type="text" name="username" id="username" value="{$item['username']}" class="form-control" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">电话</label>
                    <div class="col-sm-9">
                        <input type="text" name="mobile" id="mobile" value="{$item['mobile']}" class="form-control" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">性别</label>
                    <div class="col-sm-9">
                        <label for="sex1" class="radio-inline"><input type="radio" name="sex" value="1" id="sex1" {if empty($item) || $item['sex'] == 1}checked="true"{/if} /> 男</label>
                        &nbsp;&nbsp;&nbsp;
                        <label for="sex2" class="radio-inline"><input type="radio" name="sex" value="0" id="sex2"  {if !empty($item) && $item['sex'] == 0}checked="true"{/if} /> 女</label>
                        <span class="help-block"></span>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">身份证</label>
                    <div class="col-sm-9">
                        <input type="text" name="idcard" id="idcard" value="{$item['idcard']}" class="form-control" />
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">预存余额</label>
                    <div class="col-sm-9">
                        <input type="text" name="credit" id="credit" value="{if empty($item['credit'])}0{else}{$item['credit']}{/if}" class="form-control"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">预存积分</label>
                    <div class="col-sm-9">
                        <input type="text" name="coin" id="coin" value="{if empty($item['coin'])}0{else}{$item['coin']}{/if}" class="form-control"/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-xs-12 col-sm-3 col-md-2 control-label">状态</label>
                    <div class="col-sm-9">
                        <label for="status1" class="radio-inline"><input type="radio" name="status" value="1" id="status1" {if $item['status'] == 1}checked="true"{/if} /> 已绑定</label>
                        &nbsp;&nbsp;&nbsp;
                        <label for="status2" class="radio-inline"><input type="radio" name="status" value="0" id="status2"  {if empty($item) || !empty($item) && $item['status'] == 0}checked="true"{/if} /> 未绑定</label>
                        <span class="help-block"></span>
                    </div>
                </div>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-12">
                <button type="submit" class="btn btn-primary col-lg-1" name="submit" value="提交">提交</button>
                <input type="hidden" name="token" value="{$_W['token']}" />
            </div>
        </div>
    </form>
</div>
{/if}
{template 'common/footer'}
